package cn.tedu.car.backend.vehicleStation.service;

import cn.tedu.car.backend.base.exception.ServiceException;
import cn.tedu.car.backend.base.response.StatusCode;
import cn.tedu.car.backend.vehicleStation.mapper.VehicleMapper1;
import cn.tedu.car.backend.vehicleStation.pojo.dto.VehicleQuery;
import cn.tedu.car.backend.vehicleStation.pojo.vo.VehicleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class VehicleServiceImpl1 implements VehicleService{
    @Autowired
    private VehicleMapper1 vehicleMapper1;

    @Override
    public void unbindVehicle(Long id) {
        int unbindVehicle = vehicleMapper1.unbindVehicle(id);
        if (unbindVehicle == 0){
            throw new ServiceException(StatusCode.OPERATION_FAILED);
        }
    }
    @Override
    public List<VehicleVO> getVehicle(VehicleQuery vehicleQuery) {
        List<VehicleVO> vehicleVOList = vehicleMapper1.getVehicle(vehicleQuery);
        log.debug("返回车辆信息:{}",vehicleVOList);
        return vehicleVOList;
    }
}
